home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / sound / aiff writer sdev / componentdispatch.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  5.7 KB  |  139 lines

  1. /*
  2.     File:        ComponentDispatch.h
  3.  
  4.     Contains:    Header for common routines for dispatching for a sound component
  5.  
  6.     Written by: Mark Cookson    
  7.  
  8.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/16/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #ifndef __COMPONENTDISPATCH__
  25. #define __COMPONENTDISPATCH__
  26.  
  27. #include <Components.h>
  28. #include <Errors.h>
  29. #include <SoundComponents.h>
  30.  
  31. #ifndef __COMPONENTPROTOTYPES__
  32. #include "ComponentPrototypes.h"
  33. #endif
  34.  
  35. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. // types
  37. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38.  
  39. #if GENERATINGPOWERPC
  40.  
  41. // These structs are use in PowerMac builds to cast the
  42. // ComponentParameters passed into our component's entry point.
  43.  
  44. enum {
  45.     uppSoundComponentEntryPointProcInfo = kPascalStackBased
  46.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  47.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentParameters *)))
  48.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(void *)))
  49. };
  50.  
  51. // These are used to create the routine descriptor to call each function.
  52.  
  53. enum {
  54.         upp__SoundComponentOpenProcInfo = kPascalStackBased
  55.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  56.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *)))
  57.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ComponentInstance)))
  58. };
  59.  
  60. enum {
  61.         upp__SoundComponentCloseProcInfo = kPascalStackBased
  62.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  63.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  64.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ComponentInstance)))
  65. };
  66.  
  67. enum {
  68.         upp__SoundComponentRegisterProcInfo = kPascalStackBased
  69.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  70.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  71. };
  72.  
  73. enum {
  74.         upp__InitOutputDeviceProcInfo = kPascalStackBased
  75.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  76.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  77.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  78. };
  79.  
  80. enum {
  81.         upp__StartSourceProcInfo = kPascalStackBased
  82.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  83.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  84.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  85.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundSource *)))
  86. };
  87.  
  88. enum {
  89.         upp__SoundComponentGetInfoProcInfo = kPascalStackBased
  90.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  91.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  92.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundSource)))
  93.                 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(OSType)))
  94.                 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void *)))
  95. };
  96.  
  97. enum {
  98.         upp__SoundComponentSetInfoProcInfo = kPascalStackBased
  99.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  100.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  101.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundSource)))
  102.                 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(OSType)))
  103.                 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void *)))
  104. };
  105.  
  106. enum {
  107.         upp__SoundComponentPlaySourceBufferProcInfo = kPascalStackBased
  108.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  109.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  110.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundSource)))
  111.                 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(SoundParamBlockPtr)))
  112.                 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  113. };
  114.  
  115. #define CallComponentFunctionWithStorageUniv(storage, params, funcName) \
  116.         CallComponentFunctionWithStorage(storage, params, &funcName##RD)
  117. #define CallComponentFunctionUniv(params, funcName) \
  118.         CallComponentFunction(params, &funcName##RD)
  119. #define INSTANTIATE_ROUTINE_DESCRIPTOR(funcName) RoutineDescriptor funcName##RD = \
  120.         BUILD_ROUTINE_DESCRIPTOR (upp##funcName##ProcInfo, funcName)
  121.  
  122. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentOpen);
  123. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentClose);
  124. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentRegister);
  125. INSTANTIATE_ROUTINE_DESCRIPTOR(__InitOutputDevice);
  126. INSTANTIATE_ROUTINE_DESCRIPTOR(__StartSource);
  127. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentGetInfo);
  128. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentSetInfo);
  129. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentPlaySourceBuffer);
  130.  
  131. #else //GENERATING68K
  132.  
  133. #define CallComponentFunctionWithStorageUniv(storage, params, funcName) \
  134.         CallComponentFunctionWithStorage(storage, params, (ComponentFunctionUPP)funcName)
  135. #define CallComponentFunctionUniv(params, funcName) \
  136.         CallComponentFunction(params, (ComponentFunctionUPP)funcName)
  137. #endif
  138.  
  139. #endif //#ifndef __COMPONENTDISPATCH__